#-*- coding:utf-8 -*-

from django.db import models
from django.contrib.auth.models import User

class SType(models.Model):
    name = models.CharField(max_length=128)
    desc = models.TextField()
    tags = models.CharField(max_length=128)
    ts = models.DateTimeField(auto_now=True)

    def __unicode__(self):
        return self.name

class Shop(models.Model):
    STATUS_APPLY = 1
    STATUS_NORMAL = 2
    STATUS_DISABLED = 3
    STATUS_CHOICES = ( (STATUS_APPLY, "申请"), (STATUS_NORMAL, "正常"), (STATUS_APPLY, "禁用"),)

    owner = models.ForeignKey(User)
    stype = models.ForeignKey(SType)
    name = models.CharField(max_length=100)
    desc = models.TextField()
    foundtime = models.DateTimeField(auto_now=True)
    status = models.PositiveIntegerField(choices=STATUS_CHOICES, default=STATUS_APPLY)

    def __unicode__(self):
        return self.name
    
class Product(models.Model):
    shop = models.ForeignKey(Shop)
    name = models.CharField(max_length=100)
    desc = models.TextField()
    price = models.PositiveIntegerField()
    posttime = models.DateTimeField(auto_now=True)

    def __unicode__(self):
        return self.name

class Activity(models.Model):
    shop = models.ForeignKey(Shop)
    title = models.CharField(max_length=100)
    content = models.TextField()
    posttime = models.DateTimeField(auto_now=True)

    def __unicode__(self):
        return self.title

